package boogui.member;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.JPasswordField;

public class S_SignupDialog extends JDialog {
	
	private JTextField idTextField;
	private JTextField nameTextField;
	private JTextField hpTextField_1;
	private JTextField hpTextField_2;
	private JTextField emailTextField;
	private JPasswordField pwdField;

	public S_SignupDialog() {
		setModal(true);
		setTitle("회원가입");
		setSize(380, 480);
		setLocationRelativeTo(null);
		setResizable(false);

		getContentPane().setLayout(new BorderLayout());
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setPreferredSize(new Dimension(10, 50));
			buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("가입하기");
				okButton.addActionListener(new BtnActionListener());				
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("취소");
				cancelButton.addActionListener(new BtnActionListener());	
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
		{
			JPanel panel = new JPanel();
			getContentPane().add(panel, BorderLayout.CENTER);
			panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
			{
				JPanel panel_1 = new JPanel();
				panel.add(panel_1);
				GridBagLayout gbl_panel_1 = new GridBagLayout();
				gbl_panel_1.columnWidths = new int[] { 10, 0, 0, 0, 41, 0, 0,
						0, 0 };
				gbl_panel_1.rowHeights = new int[] { 35, 0, 20, 0, 20, 0, 20,
						0, 20, 0, 20, 20, 0, 20, 0, 0 };
				gbl_panel_1.columnWeights = new double[] { 0.0, 0.0, 0.0, 1.0,
						0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
				gbl_panel_1.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0,
						0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
						Double.MIN_VALUE };
				panel_1.setLayout(gbl_panel_1);
				{
					JLabel lblNewLabel = new JLabel("아   이   디");
					GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
					gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel.gridx = 1;
					gbc_lblNewLabel.gridy = 1;
					panel_1.add(lblNewLabel, gbc_lblNewLabel);
				}
				{
					idTextField = new JTextField();
					GridBagConstraints gbc_idTextField = new GridBagConstraints();
					gbc_idTextField.gridwidth = 3;
					gbc_idTextField.fill = GridBagConstraints.HORIZONTAL;
					gbc_idTextField.insets = new Insets(0, 0, 5, 5);
					gbc_idTextField.gridx = 3;
					gbc_idTextField.gridy = 1;
					panel_1.add(idTextField, gbc_idTextField);
					idTextField.setMargin(new Insets(3, 3, 3, 3));
					idTextField.setColumns(10);
				}
				{
					JButton idBtn = new JButton("아이디 확인");
					GridBagConstraints gbc_idBtn = new GridBagConstraints();
					idBtn.addActionListener(new BtnActionListener());
					idBtn.setActionCommand("idchk");
					gbc_idBtn.fill = GridBagConstraints.HORIZONTAL;
					gbc_idBtn.insets = new Insets(0, 0, 5, 5);
					gbc_idBtn.gridx = 6;
					gbc_idBtn.gridy = 1;
					panel_1.add(idBtn, gbc_idBtn);
				}
				{
					JLabel lblNewLabel_1 = new JLabel("비 밀 번 호");
					GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
					gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel_1.gridx = 1;
					gbc_lblNewLabel_1.gridy = 3;
					panel_1.add(lblNewLabel_1, gbc_lblNewLabel_1);
				}
				{
					pwdField = new JPasswordField();
					GridBagConstraints gbc_pwdField = new GridBagConstraints();
					gbc_pwdField.gridwidth = 3;
					gbc_pwdField.insets = new Insets(0, 0, 5, 5);
					gbc_pwdField.fill = GridBagConstraints.HORIZONTAL;
					gbc_pwdField.gridx = 3;
					gbc_pwdField.gridy = 3;
					panel_1.add(pwdField, gbc_pwdField);
				}
				{
					JLabel lblNewLabel_2 = new JLabel("이         름");
					GridBagConstraints gbc_lblNewLabel_2 = new GridBagConstraints();
					gbc_lblNewLabel_2.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel_2.gridx = 1;
					gbc_lblNewLabel_2.gridy = 5;
					panel_1.add(lblNewLabel_2, gbc_lblNewLabel_2);
				}
				{
					nameTextField = new JTextField();
					GridBagConstraints gbc_nameTextField = new GridBagConstraints();
					gbc_nameTextField.gridwidth = 3;
					gbc_nameTextField.fill = GridBagConstraints.HORIZONTAL;
					gbc_nameTextField.insets = new Insets(0, 0, 5, 5);
					gbc_nameTextField.gridx = 3;
					gbc_nameTextField.gridy = 5;
					panel_1.add(nameTextField, gbc_nameTextField);
					nameTextField.setMargin(new Insets(3, 3, 3, 3));
					nameTextField.setColumns(10);
				}
				{
					JLabel lblNewLabel_3 = new JLabel("핸   드   폰");
					GridBagConstraints gbc_lblNewLabel_3 = new GridBagConstraints();
					gbc_lblNewLabel_3.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel_3.gridx = 1;
					gbc_lblNewLabel_3.gridy = 7;
					panel_1.add(lblNewLabel_3, gbc_lblNewLabel_3);
				}
				{
					String[] hp = { "010", "011", "016", "017", "018", "019" };
					JComboBox hpCbx = new JComboBox(hp);
					GridBagConstraints gbc_hpCbx = new GridBagConstraints();
					gbc_hpCbx.fill = GridBagConstraints.HORIZONTAL;
					gbc_hpCbx.insets = new Insets(0, 0, 5, 5);
					gbc_hpCbx.gridx = 3;
					gbc_hpCbx.gridy = 7;
					panel_1.add(hpCbx, gbc_hpCbx);
				}
				{
					hpTextField_1 = new JTextField();
					GridBagConstraints gbc_hpTextField_1 = new GridBagConstraints();
					gbc_hpTextField_1.fill = GridBagConstraints.HORIZONTAL;
					gbc_hpTextField_1.insets = new Insets(0, 0, 5, 5);
					gbc_hpTextField_1.gridx = 4;
					gbc_hpTextField_1.gridy = 7;
					panel_1.add(hpTextField_1, gbc_hpTextField_1);
					hpTextField_1.setMargin(new Insets(3, 3, 3, 3));
					hpTextField_1.setColumns(4);
				}
				{
					hpTextField_2 = new JTextField();
					GridBagConstraints gbc_hpTextField_2 = new GridBagConstraints();
					gbc_hpTextField_2.fill = GridBagConstraints.HORIZONTAL;
					gbc_hpTextField_2.insets = new Insets(0, 0, 5, 5);
					gbc_hpTextField_2.gridx = 5;
					gbc_hpTextField_2.gridy = 7;
					panel_1.add(hpTextField_2, gbc_hpTextField_2);
					hpTextField_2.setMargin(new Insets(3, 3, 3, 3));
					hpTextField_2.setColumns(4);
				}
				{
					JButton hpBtn = new JButton("핸드폰 확인");
					GridBagConstraints gbc_hpBtn = new GridBagConstraints();
					hpBtn.addActionListener(new BtnActionListener());
					hpBtn.setActionCommand("hpchk");
					gbc_hpBtn.anchor = GridBagConstraints.WEST;
					gbc_hpBtn.insets = new Insets(0, 0, 5, 5);
					gbc_hpBtn.gridx = 6;
					gbc_hpBtn.gridy = 7;
					panel_1.add(hpBtn, gbc_hpBtn);
				}
				{
					JLabel lblNewLabel_4 = new JLabel("이   메   일");
					GridBagConstraints gbc_lblNewLabel_4 = new GridBagConstraints();
					gbc_lblNewLabel_4.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel_4.gridx = 1;
					gbc_lblNewLabel_4.gridy = 9;
					panel_1.add(lblNewLabel_4, gbc_lblNewLabel_4);
				}
				{
					emailTextField = new JTextField();
					GridBagConstraints gbc_emailTextField = new GridBagConstraints();
					gbc_emailTextField.gridwidth = 3;
					gbc_emailTextField.fill = GridBagConstraints.HORIZONTAL;
					gbc_emailTextField.insets = new Insets(0, 0, 5, 5);
					gbc_emailTextField.gridx = 3;
					gbc_emailTextField.gridy = 9;
					panel_1.add(emailTextField, gbc_emailTextField);
					emailTextField.setMargin(new Insets(3, 3, 3, 3));
					emailTextField.setColumns(10);
				}
				String[] email = { "직접입력", "naver.com", "hanmail.net",
						"gmail.com", "nate.com" };
				JComboBox emailCbx = new JComboBox(email);
				GridBagConstraints gbc_emailCbx = new GridBagConstraints();
				gbc_emailCbx.anchor = GridBagConstraints.WEST;
				gbc_emailCbx.insets = new Insets(0, 0, 5, 5);
				gbc_emailCbx.gridx = 6;
				gbc_emailCbx.gridy = 9;
				panel_1.add(emailCbx, gbc_emailCbx);
				{
					JButton emailBtn = new JButton("이메일 확인");
					GridBagConstraints gbc_emailBtn = new GridBagConstraints();
					emailBtn.addActionListener(new BtnActionListener());
					emailBtn.setActionCommand("emailchk");
					gbc_emailBtn.fill = GridBagConstraints.HORIZONTAL;
					gbc_emailBtn.gridwidth = 2;
					gbc_emailBtn.insets = new Insets(0, 0, 5, 5);
					gbc_emailBtn.gridx = 5;
					gbc_emailBtn.gridy = 10;
					panel_1.add(emailBtn, gbc_emailBtn);
				}

				{
					JLabel lblNewLabel_5 = new JLabel("생 년 월 일");
					GridBagConstraints gbc_lblNewLabel_5 = new GridBagConstraints();
					gbc_lblNewLabel_5.insets = new Insets(0, 0, 5, 5);
					gbc_lblNewLabel_5.gridx = 1;
					gbc_lblNewLabel_5.gridy = 12;
					panel_1.add(lblNewLabel_5, gbc_lblNewLabel_5);
				}

				String[] year = new String[100];
				for (int i = 0; i < year.length; ++i) {
					year[i] = (2013 - i) + "년";
				}
				JComboBox yearCbx = new JComboBox(year);
				GridBagConstraints gbc_yearCbx = new GridBagConstraints();
				gbc_yearCbx.fill = GridBagConstraints.HORIZONTAL;
				gbc_yearCbx.insets = new Insets(0, 0, 5, 5);
				gbc_yearCbx.gridx = 3;
				gbc_yearCbx.gridy = 12;
				panel_1.add(yearCbx, gbc_yearCbx);

				String[] day = new String[31];
				for (int i = 0; i < day.length; ++i) {
					day[i] = (i + 1) + "일";
				}
				JComboBox monthCbx = new JComboBox(day);
				GridBagConstraints gbc_monthCbx = new GridBagConstraints();
				gbc_monthCbx.fill = GridBagConstraints.HORIZONTAL;
				gbc_monthCbx.insets = new Insets(0, 0, 5, 5);
				gbc_monthCbx.gridx = 4;
				gbc_monthCbx.gridy = 12;
				panel_1.add(monthCbx, gbc_monthCbx);

				String[] month = new String[31];
				for (int i = 0; i < month.length; ++i) {
					month[i] = (i + 1) + "월";
				}
				JComboBox dayCbx = new JComboBox(month);
				GridBagConstraints gbc_dayCbx = new GridBagConstraints();
				gbc_dayCbx.anchor = GridBagConstraints.WEST;
				gbc_dayCbx.insets = new Insets(0, 0, 5, 5);
				gbc_dayCbx.gridx = 5;
				gbc_dayCbx.gridy = 12;
				panel_1.add(dayCbx, gbc_dayCbx);
				{
					JLabel lblNewLabel_6 = new JLabel("선 호 장 르");
					GridBagConstraints gbc_lblNewLabel_6 = new GridBagConstraints();
					gbc_lblNewLabel_6.insets = new Insets(0, 0, 0, 5);
					gbc_lblNewLabel_6.gridx = 1;
					gbc_lblNewLabel_6.gridy = 14;
					panel_1.add(lblNewLabel_6, gbc_lblNewLabel_6);
				}
				String[] g = { "액션", "드라마", "멜로/로맨스", "코미디", "스릴러", "공포" };
				JComboBox comboBox_3 = new JComboBox(g);
				GridBagConstraints gbc_comboBox_3 = new GridBagConstraints();
				gbc_comboBox_3.fill = GridBagConstraints.HORIZONTAL;
				gbc_comboBox_3.gridwidth = 3;
				gbc_comboBox_3.insets = new Insets(0, 0, 0, 5);
				gbc_comboBox_3.gridx = 3;
				gbc_comboBox_3.gridy = 14;
				panel_1.add(comboBox_3, gbc_comboBox_3);

			}
		}

		setVisible(true);
	}

	private class BtnActionListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			MemberChkService chks = new MemberChkService();
			boolean result = false;
			String str = "";
			switch (e.getActionCommand()) {
			case "idchk":
				str = idTextField.getText();
				JOptionPane.showMessageDialog(null, chks.dupChkId(str));				
				break;
			case "hpchk":
				break;
			case "emailchk":
				break;
			case "OK":
				break;
			case "Cancel":
				setVisible(false);
				break;
			}

		}

	}

}
